package com.heima.wemedia.controller.v1;

import com.heima.model.comment.dtos.ApCommentDto;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.CommentGetListDto;
import com.heima.model.wemedia.dtos.ManageDto;
import com.heima.wemedia.service.ManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comment/manage")
public class ManageController {

    @Autowired
    private ManageService manageService;

    @PostMapping("/find_news_comments")
    public PageResponseResult findNewsComments(@RequestBody ManageDto dto){
        return manageService.getNewsList(dto);
    }

    /**
     * 打开或关闭评论
     * @param dto
     * @return
     */
    @PostMapping("update_comment_status")
    public ResponseResult updateCommentStatus(@RequestBody ApCommentDto dto){
        return manageService.updateCommentStatus(dto);
    }

    /**
     * 查看评论
     */
    @PostMapping("/list")
    public ResponseResult getList(@RequestBody CommentGetListDto dto){
        return manageService.getList(dto);
    }

    @PostMapping("/comment_repay")
    public ResponseResult commentRepay(@RequestBody ApCommentDto dto){
        return manageService.authorSave(dto);
    }

    @PostMapping("/like")
    public ResponseResult authLike(@RequestBody ApCommentDto dto){
        return manageService.authLike(dto);
    }
}
